# Maintainer: Rafal Brzegowy <rafal.brzegowy@yahoo.com>

_realname=tfel
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=3.4.0
pkgrel=1
pkgdesc='MFront: a code generation tool dedicated to material knowledge (mingw-w64)'
arch=('any')
provides=('mfront')
depends=("${MINGW_PACKAGE_PREFIX}-gnuplot")
makedepends=("unzip"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-cmake")
#optdepends=("")
license=('GPL')
url='http://tfel.sourceforge.net'
source=(https://github.com/thelfer/${_realname}/archive/TFEL-${pkgver}.zip)
sha256sums=('603FE64C2FD1584F233B08200C57F65D1214EB741B85FD636172DA3E369467E5')
noextract=("TFEL-${pkgver}.zip") # bsdtar could not unpack this archive

prepare() {  
  rm -rf "${srcdir}/TFEL-${pkgver}r"
  unzip -oq TFEL-${pkgver}.zip -d ${srcdir}
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    ${MINGW_PREFIX}/bin/cmake \
      -GNinja \
      -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
      -DCMAKE_BUILD_TYPE=Release \
      -Denable-fortran=ON \
      -Denable-python=OFF \
      -Denable-python-bindings=OFF \
      -Denable-aster=ON \
      -Denable-abaqus=ON \
      -Denable-ansys=ON \
      -Denable-europlexus=ON \
      -Denable-zmat=ON \
      -Denable-cyrano=ON \
      -Denable-calculix=ON \
      -Denable-comsol=ON \
      -Denable-diana-fea=ON \
      -Denable-lsdyna=ON \
      -Denable-cxx-17=ON \
      -Denable-portable-build=ON \
      -Denable-reference-doc=OFF \
      ../${_realname}-TFEL-${pkgver}
  ninja
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  DESTDIR=${pkgdir} cmake --build . --target install
  install -Dm644 ${srcdir}/${_realname}-TFEL-${pkgver}/LICENCE-GNU-GPL ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

# vim: ts=2 sw=2 et:
